package com.xyz.app.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.xyz.app.inter.HtmlParser;

public class TestHtmlParser implements HtmlParser {

    private String host;

    public TestHtmlParser(String host) {
        this.host = host;
    }

    @Override
    public List<Map<String, String>> parseList(String url, String content) {
        System.out.println("url:" + url);
        final List<Map<String, String>> mediaInfos = new ArrayList<Map<String, String>>(50);

        try {
            for (int i = 0; i < 20; i++) {
                Map<String, String> media = new HashMap<String, String>();
                media.put("link",
                        "https://meyerweb.com/eric/tools/dencoder/");
                media.put("title", "滴滴稳定性建设实践");
                media.put("preview", "https://res.infoq.com/presentations/construction-practice-of-xiaojukeji-stability/zh/mediumimage/zhangyunliu270-1517056142256.jpg");
                media.put("duration", "22:34");
                media.put("linkHost", host);
                // ele.select(".bg").get(0).select("strong").get(0).html());
                mediaInfos.add(media);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return mediaInfos;
        // TODO Auto-generated method stub
        // return null;
    }

    @Override
    public Map<String, String> parseDetail(String url, String content) {
        System.out.println("url:" + url);
        Map<String, String> media = new HashMap<String, String>();
        String vurl = "http://cm14-ccm1-2.play.bokecc.com/flvs/ca/QxEII/ubDJUGNAH2-10.mp4?t=1518408369&key=069F3CCFC141331397B335C7CB567E8D";
        media.put("videoUrl", vurl);
        media.put("downloadUrl", vurl);
        return media;
    }

    @Override
    public String getUrl(String url, int page) {
        System.out.println("url:" + url + "|page:" + page);
        return url + "/" + page * 12;
    }

}
